//
//  YWAllAlbumsViewController.m
//  聆听FM
//
//  Created by dllo on 16/6/17.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "YWAllAlbumsViewController.h"
#import "ZCSTipsReTableViewCell.h"
#import "YWAnchorIntroduceAlbumsModel.h"

@interface YWAllAlbumsViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) NSMutableArray *allAlbumArray;

@property (nonatomic, assign) NSInteger maxPageId;
//专辑数量
@property (nonatomic, assign) NSInteger totalCount;

@property (nonatomic, retain) UITableView *allAlbumTableView;

@end

@implementation YWAllAlbumsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"全部专辑";
    [self getView];
    self.allAlbumArray = [NSMutableArray array];
    [self getData];
}

- (void)getView
{
    self.allAlbumTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT) style:UITableViewStylePlain];
    _allAlbumTableView.delegate = self;
    _allAlbumTableView.dataSource = self;
    _allAlbumTableView.separatorStyle = NO;
    [self.view addSubview:_allAlbumTableView];
    
    [_allAlbumTableView registerNib:[UINib nibWithNibName:@"ZCSTipsReTableViewCell" bundle:nil] forCellReuseIdentifier:@"TipCell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _allAlbumArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZCSTipsReTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TipCell"];
    cell.introduceAlbumsModel = [_allAlbumArray objectAtIndex:indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90;
}

- (void)getData
{
    NSString *urlString = [NSString stringWithFormat:@"http://mobile.ximalaya.com/mobile/v1/artist/albums?toUid=%ld", _uid];
    [LTNetTool GetNetWithURL:urlString Body:nil Header:nil Response:LTJSON Success:^(id result) {
        NSArray *tempArray = [result objectForKey:@"list"];
        for (NSDictionary *dic in tempArray) {
            YWAnchorIntroduceAlbumsModel *albumModel = [[YWAnchorIntroduceAlbumsModel alloc] initWithDic:dic];
            [_allAlbumArray addObject:albumModel];
        }
        [_allAlbumTableView reloadData];
    } Failure:^(NSError *error) {
        NSLog(@"请求失败");
    }];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
